#include <bits/stdc++.h>
using namespace std;
int T;
int n;
int a[200010];
long long ans;
bool color[200010];
void dfs(int dep)
{
    if (dep==n+1)
    {
        long long sum=0;
        for (int i=1;i<=n;i++)
        {
            int num=-1;
            for (int j=i-1;j>=1;j--)
            {
                if (color[i]==color[j])
                {
                    num=a[j];
                    break;
                }
            }
            if (num==a[i])
            {
                sum+=a[i];
            }
        }
        ans=max(ans,sum);
        return ;
    }
    color[dep]=true;
    dfs(dep+1);
    color[dep]=false;
    dfs(dep+1);
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    a[0]=-1;
    scanf("%d",&T);
    while (T--)
    {
        scanf("%d",&n);
        for (int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
        }
        ans=0;
        dfs(1);
        printf("%lld\n",ans);
    }
    return 0;
}
